Learn R Programming

gridSVG (version 1.0-1)

Import JS as JSON: Importing JavaScript coordinate information as JSON.

Description

This function reads in a JavaScript file and transforms it into JSON text.

Usage

readCoordsJS(filename)

Arguments

filename
A character vector that represents a file name. This file should be a JavaScript file containing coordinate information produced by gridToSVG.

Value

  • A single element character vector is returned, representing a JSON object.

Details

In order to use the fromJSON function to parse JSON text, the JavaScript file produced by gridToSVG needs to be transformed. It needs to transform from being an assignment of an object literal to simply the object literal itself.

This function performs that task by producing a valid JSON string ready for parsing by fromJSON.